<?php
	
	$keys = array_keys($_POST);
	$move_ids = array();
	foreach ($keys as $ids){
		if (strstr($ids, "item")){
			$move_ids[] = $ids;
			$at_least_one = true;
		}
	}

	if ($at_least_one != true){
		oyster_log("ERROR", (string)$language->errors->value_22, "MonaLisa insert_new");
		$head->_template_assign("ERROR", (string)$language->errors->value_22);
	} else {
		$expo_name_new = "./Applications/monalisa/Expositions/Expo.expo";
		
		if (file_exists($expo_name_new)){
			$expo_name_new = don3_plus_one("Expo.expo", "./Applications/monalisa/Expositions/");
		}
		
		$expo_new = sqlite_open($expo_name_new, 0666);
		$now = time();
		$write = sqlite_query($expo_new, 
					"CREATE TABLE expo(
						id INTEGER NOT NULL PRIMARY KEY,
						exhibit longtext,
						type VARCHAR(6))");
		$filename = (string)$language->common->value_49;				
		$write .= sqlite_query($expo_new, "INSERT INTO expo (exhibit, type) VALUES ('$filename', 'desc')");
		$write .= sqlite_query($expo_new, "INSERT INTO expo (exhibit, type) VALUES ('$now', 'date')");
		$error = 0;
		$files = 0;
		foreach ($move_ids as $ids){
			if (is_file($_POST[$ids]) AND !is_restricted($_POST[$ids])){
				$xibit = $_POST[$ids];
				$write .= sqlite_query($expo_new, "INSERT INTO expo (exhibit, type) VALUES ('$xibit', 'file')");
				$files++;
			} else {
				oyster_log("ERROR", (string)$language->errors->value_23, "MonaLisa insert_new");
				$error++;
			}
		}
		sqlite_close($expo_new);
	}
	
	if ($error != 0 AND $files == 0){
		oyster_log("ERROR", sprintf((string)$language->errors->value_24, $error), "MonaLisa insert_new");
		$head->_template_assign("ERROR", sprintf((string)$language->errors->value_24, $error));
	} elseif ($error != 0 AND $files > 0) {
		oyster_log("ERROR", sprintf((string)$language->errors->value_24, $error), "MonaLisa insert_new");
		$head->_template_assign("ERROR", sprintf((string)$language->errors->value_24, $error));
		oyster_log("SUCCESS", sprintf((string)$language->stati->value_10, $files), "MonaLisa insert_new");
		$head->_template_assign("STATUS", sprintf((string)$language->stati->value_10, $files));
	} else {
		oyster_log("SUCCESS", sprintf((string)$language->stati->value_10, $files), "MonaLisa insert_new");
		$head->_template_assign("STATUS", sprintf((string)$language->stati->value_10, $files));
	}
	$ordner = $_GET["path"];
	$included = true;
	include("System/Kernel/Includes/index.include.php");
?>